package com.liaowei.user.controller;

import com.liaowei.common.BaseResponse;
import com.liaowei.common.ResultUtils;
import com.liaowei.model.domain.Tag;
import com.liaowei.model.param.UserTagParam;
import com.liaowei.user.service.UserTagService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("tags")
@RequiredArgsConstructor
public class UserTagController {

    private final UserTagService userTagService;

    // 保存自己的兴趣标签
    @PostMapping
    public BaseResponse<String> saveInterestTagList(@RequestBody @Validated UserTagParam userTagParam){
        return ResultUtils.success(userTagService.saveInterestTagList(userTagParam));
    }

    // 查询自己的兴趣标签
    @GetMapping("interest/{userId}")
    public BaseResponse<List<Tag>> interestTagList(@PathVariable long userId){
        return ResultUtils.success(userTagService.searchInterestTagList(userId));
    }

    // 根据标签删除用户标签记录
    @DeleteMapping("{tagId}")
    public BaseResponse<String> deleteUserTagByTagId(@PathVariable long tagId){
        return ResultUtils.success(userTagService.deleteByTagId(tagId));
    }
}
